#include "mkdir.h"
void mkDir(int peerfd, char *pathname){
    if(strcmp(pathname, " ") == 0){ 
        char msg[1024] = "路径名为空，请重新输入。";
        int length = strlen(msg);
        train_t train;
        memset(&train, 0, sizeof(train));
        train.len = length;
        strcpy(train.data, msg);
        send(peerfd, &train, 4 + train.len, MSG_WAITALL);
        return;
    }   
    int retval = mkdir(pathname, 0777);
    if(retval == -1){
        char errmsg[1024] = {0};
        sprintf(errmsg, "%s", strerror(errno));
        train_t train;
        train.len = strlen(errmsg);
        strcpy(train.data, errmsg);
        send(peerfd, &train, 4 + train.len, MSG_WAITALL);
        return;
    }   
    char sucessmsg[1024] = "mkdir sucess.";
    train_t train;
    train.len = strlen(sucessmsg);
    strcpy(train.data, sucessmsg);
    send(peerfd, &train, 4 + train.len, MSG_WAITALL);
    return;    
}
